package com.ludomancy.gamelib;

import java.util.Date;
import java.util.Properties;

import com.ludomancy.gamelib.DataUtil.DataUtilCookieNotFoundException;
import com.ludomancy.gamelib.DataUtil.DataUtilCookieNotSupportedException;
import com.ludomancy.gamelib.DataUtil.DataUtilCookieParseException;

public class DataStorage
{
	public static void save(String key, Properties properties)
	{
		DataUtil dataManager = new DataUtil(GameApplet.gameAppletInstance);

		Date expireDate=new Date();
		expireDate.setYear(expireDate.getYear()+3);
		
		try
		{
			dataManager.write(properties, key, expireDate);
		}
		catch (DataUtilCookieParseException e)
		{
		}
		catch (DataUtilCookieNotSupportedException e)
		{
		}
		catch(Exception e)
		{
		}
	}
	
	public static Properties load(String key)
	{
		DataUtil dataManager = new DataUtil(GameApplet.gameAppletInstance);
		try
		{
			return dataManager.read(key);
		} 
		catch (DataUtilCookieParseException e)
		{
		} 
		catch (DataUtilCookieNotFoundException e)
		{
		} 
		catch (DataUtilCookieNotSupportedException e)
		{
		}
		return null;
	}
}
